package cn.harry.cabinet.dao

import androidx.room.*
import cn.harry.cabinet.model.entity.Cabinet

/**
 * 柜表数据访问对象
 */
@Dao
interface CabinetDao {
    
    @Query("SELECT * FROM cabinets")
    fun getAllCabinets(): List<Cabinet>
    
    @Query("SELECT * FROM cabinets WHERE id = :id")
    fun getCabinetById(id: Long): Cabinet?
    
    @Query("SELECT * FROM cabinets WHERE cabinetNumber = :cabinetNumber")
    fun getCabinetByNumber(cabinetNumber: String): Cabinet?
    
    @Query("SELECT * FROM cabinets WHERE status = :status")
    fun getCabinetsByStatus(status: cn.harry.cabinet.model.enums.CabinetStatus): List<Cabinet>
    
    @Insert
    fun insertCabinet(cabinet: Cabinet): Long
    
    @Update
    fun updateCabinet(cabinet: Cabinet)
    
    @Delete
    fun deleteCabinet(cabinet: Cabinet)
    
    @Query("DELETE FROM cabinets")
    fun deleteAllCabinets()
}